package root.LocalityBasedLeastConnectionsScheduling;

import java.util.concurrent.atomic.AtomicInteger;

// 服务器类，表示一个服务器
class Server {
    private String name;
    private AtomicInteger connections;
    private String locality; // 服务器的局部性（例如数据中心位置）

    public Server(String name, String locality) {
        this.name = name;
        this.connections = new AtomicInteger(0);
        this.locality = locality;
    }

    public String getName() {
        return name;
    }

    public int getConnections() {
        return connections.get();
    }

    public void incrementConnections() {
        connections.incrementAndGet();
    }

    public void decrementConnections() {
        connections.decrementAndGet();
    }

    public String getLocality() {
        return locality;
    }
}